package cn.gdcp.listviewtestbaseadapter;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;

public class AddStudent extends AppCompatActivity {
          EditText nameEdit;
         EditText ageEdit;
        RadioButton radiom1;
     RadioButton radiom2;
       RadioButton radiom3;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_student);
        Button button=(Button)findViewById(R.id.submit);
         nameEdit=findViewById(R.id.add_name);
         ageEdit=findViewById(R.id.add_age);
         radiom1=findViewById(R.id.m1);
          radiom2=findViewById(R.id.m2);
          radiom3=findViewById(R.id.m3);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                String name=nameEdit.getText().toString();
                String age=ageEdit.getText().toString();

               int imgId=0;
                if(radiom1.isChecked())
                {  imgId=R.drawable.m1;}
                else if(radiom2.isChecked()){
                    imgId=R.drawable.m2;
                }
                else if(radiom3.isChecked()){
                    imgId=R.drawable.m3;
                }

              Intent intent=new Intent();
              intent.putExtra("AGE",age);
                intent.putExtra("NAME",name);
               intent.putExtra("IMGID",imgId);
                setResult(202,intent);
                finish();
            }
        });
    }


}
